package net.peelmeagrape.hibernate;

import net.peelmeagrape.hibernate.xmlgen.XmlAttribute;
import net.peelmeagrape.hibernate.xmlgen.XmlElement;
import net.peelmeagrape.hibernate.xmlgen.XmlText;

import static java.lang.annotation.ElementType.*;
import java.lang.annotation.Retention;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
import java.lang.annotation.Target;
//todo: can these be defined in a package.java?

/**
 * See {@link Filter} and
 * <a href="{@docRoot}/reference/en/html/filters.html#filters">Hibernate Documentation for filters</a>.
 */
@Target({METHOD,FIELD,CONSTRUCTOR,TYPE,PACKAGE})
@Retention(RUNTIME)
@XmlElement(name="filter-def", parent="hibernate-mapping")
public @interface FilterDef
{
    @XmlText String query() default "";

    @XmlAttribute String name();
    @XmlAttribute String condition() default "";

    Param[] params() default {};

    /**
     * Parameter to a {@link FilterDef}.
     */
    @XmlElement(name="filter-param")
    public @interface Param {
        @XmlAttribute String name();
        @XmlAttribute String type();
    }
}
